// mixins/routeListener.js
import { getStorage } from "@/utils/storage";
import { getEnv } from "@/utils/env";
export default {
  onLoad() {
    // console.log("页面加载", this.route);
  },
  onUnload() {
    // console.log("页面卸载", this.route);
  },
  onShow() {
    console.log("页面显示", this.route);
    console.log(this.route);
    if (getEnv() == "WX_PUBLIC") {
      let page = ["pages/goods/detail"];
      if (!page.includes(this.route)) {
        let link = window.location.href;
        if (link.indexOf("?") == -1) {
          link = `${link}?uid=${getStorage("userinfo").id}`;
        } else {
          link = `${link}&uid=${getStorage("userinfo").id}`;
        }
        this.$jwx.updateTimelineShareData({
          title: "",
          link,
          imgUrl: "",
          callback: function (res) {},
        });

        this.$jwx.updateAppMessageShareData({
          desc: "",
          title: "",
          link,
          imgUrl: "",
          callback: function (res) {},
        });
      }
    }
  },
  onHide() {
    // console.log("页面隐藏", this.route);
  },
};
